<?php
if(isset($form['#upgrade_user'])&& !empty($form['#upgrade_user'])) {
    print _user_base_header_info();
}
?>
<?php
if(isset($form['#addr_id'])&& !empty($form['#addr_id'])) {
echo get_template_header_info($form['#addr_id'], 'village');
}
?>
<?php

if (arg(1) == "edit"  && !empty($_GET['farmer_id'])) {
    echo get_template_header_info(arg(2));
}
 ?>

<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }else if(!empty($_GET['addr_id'])){ ?>
        <img style="margin-left: 85px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/village.png"/>
    <?php }?>
    <ul class="j-sw-nav">
    <?php
        if(arg(1) == 'add' && empty($_GET['addr_id'])){?>
                <li class="newprd-s1 tab-li"><a href="<?php echo base_path(); ?>farmer/list">查看</a></li>
            <?php if(user_access('add farmer')){?>
                <li class="newprd-s2 tab-li on"><a href="<?php echo base_path(); ?>farmer/add">添加</a></li>
        <?php }
         }else if(arg(1) == 'add' && !empty($_GET['addr_id'])){?>
            <?php echo get_tab($_GET['addr_id'],'farmer','village'); ?>
        <?php }else if(arg(1) == 'edit' && !empty($_GET['farmer_id'])){?>
            <?php echo get_tab(arg(2),'farmer_edit'); ?>
        <?php }else if(arg(1) == 'edit' && !empty($_GET['addr_id'])){?>
            <?php echo get_tab($_GET['addr_id'],'farmer','village'); ?>
        <?php }else if(arg(1) == 'edit' && empty($_GET['farmer_id']) && empty($_GET['addr_id']) && empty($_GET['upgrade_id'])){?>
            <li class="newprd-s1 tab-li"><a href="<?php echo base_path(); ?>farmer/list">查看</a></li>
            <li class="newprd-s2 tab-li"><a href="<?php echo base_path(); ?>farmer/add">添加</a></li>
            <li class="newprd-s3 tab-li on"><a href="javascript:void(0)">修改</a></li>
        <?php }?>
        </ul>
        <div class="newprd-s1">
         <div class="table-div">
        <div class="small-select small-input column" style="clear:both">
            <?php  print _address_render_for_add($form)?>
        </div>
        <div <?php
            global $user;
            $info = _get_user_info($user->uid);
            $upgrading_user = ($info['role'] == "升级成农户");
            if($_GET['farmer_id'] || $_GET['addr_id'] || $upgrading_user) {echo "style='display:none;'";}?>>
            <div class="form-label">导入农户:</div><?php print render($form['file']['file_upload']); ?>
            <span style="margin-left:80px">(注:请选择上传的excel文件)</span>
            <div style="text-align: left;margin-bottom: 10px;margin-left: 150px;"><?php print render($form['file']['submit']); ?></div>
        </div>
        <div class="small-select max-big-input column" style="clear:both">
            <div class="form-label">详细地址:</div><?php print render($form['details']); ?>
        </div>
             <div class="small-select max-big-input column" style="clear:both">
                 <div class="form-label">专项活动:</div><?php print render($form['special_activities']); ?>
             </div>
        <div class="small-select column" style="clear:both">
            <div class="small-input small-div"><div class="form-label"><span class="required">*</span>姓名(导入下非必填):</div><?php print render($form['farmer_name']); ?></div>
            <div class="small-div"><div class="form-label">性别:</div><div class="gender"><?php print render($form['gender']); ?></div></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label"><span class="required">*</span>手机(导入下非必填):</div><?php print render($form['cell']); ?></div>
            <div class="small-div"><div class="form-label">电话号码 :<br/>(如：010-1234567)</div><?php print render($form['phone']); ?></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label">邮箱:</div><?php print render($form['email']); ?></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label">农户类型:</div><?php print render($form['type']); ?></div>
            <div class="small-div"><div class="form-label">耕地面积（亩）:</div><?php print render($form['farm_area']); ?></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label">土壤种类:</div><?php print render($form['soil_type']); ?></div>
            <div class="small-div"><div class="form-label">肥沃程度:</div><?php print render( $form['soil_fertility']); ?></div>
        </div>
         <div class="max-big-input address-search">
             <?php if(user_access('view own distributor') || user_access('view all distributor')){?><div class="form-label">经销商:</div>
             <?php } print render($form['distributor_name']);
             print render($form['select_distributor_button']);
             ?>
         </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="form-label">备注:</div><div style="margin-left: 11.3em; "><?php print render($form['farmer_other']['comments']); ?></div>
        </div>
        <div class="add-submit" style="text-align: center"><?php print render($form['submit']); ?></div>
             <?php if(isset($_GET['addr_id'])&& !empty($_GET['addr_id'])){?>
                 <ul class="table-ul-li">
                     <li  style=" padding: 2em 0;float: right; margin-top: -5.8em;margin-right: 24em;"><a href="<?php echo base_path(); ?>farmer/list?addr_id=<?php echo $_GET['addr_id']?>">
                             <input class="btn btn-primary form-submit" type="button"  value="返回">
                         </a></li>
<!--                     --><?php //if(user_access('add fertilizer_case')){?>
<!--                         <li>|</li>-->
<!--                         <li><a href="--><?php //echo base_path(); ?><!--farmer/add?addr_id=--><?php //echo $_GET['addr_id']?><!--" --><?php //if(arg(1) == "add" && !empty($_GET['addr_id'])){?><!--class="selected"--><?php //}?><!--添加</a></li>-->
<!--                     --><?php //}
//                     if(arg(1) == "edit" && !empty($_GET['addr_id'])){?>
<!--                         <li>|</li>-->
<!--                         <li class="selected">详情</li>-->
<!--                     --><?php //}?>
                 </ul>
             <?php }?>
             <div style="clear: both"></div>
    </div>
</div>
</div>

<?php print drupal_render_children($form); ?>
</div></form>
<div>
    <div class="modal fade" id="distributorModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        选择经销商
                    </h4>
                </div>
                <div class="modal-body">
                    <?php echo @render(drupal_get_form('distributor_select_list_form'),$_GET['addr_id']?$_GET['addr_id']:'');?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<form><div>
